import { defHttp } from "/@/utils/http/axios";

//  获取商品品牌分页列表
export const getManagerBrandPage = (params) => {
    return defHttp.get({url:'/manager/goods/brand/getByPage', params}, {joinParamsToUrl: true});
}

// 批量删除
export const delBrand = (ids) =>{
    return defHttp.delete({url:`/manager/goods/brand/delByIds/${ids}`});
}

//  添加
export const addBrand = (params) => {
    return defHttp.post({url:'/manager/goods/brand', params}, {joinParamsToUrl: true});
}
// 修改品牌设置
export const updateBrand = (params) => {
    return defHttp.put({url:`/manager/goods/brand/${params.id}`, params}, {joinParamsToUrl: true});
}
// 禁用品牌
export const disableBrand = (id, params) => {
    return defHttp.put({url:`/manager/goods/brand/disable/${id}`, params}, {joinParamsToUrl: true});
}
//根据分类id获取关联品牌
export const getCategoryBrandListData = (category_id, params) => {
    return defHttp.get({url:`/manager/goods/categoryBrand/${category_id}`, params}, {joinParamsToUrl: true});
}
//保存获取关联品牌
export const saveCategoryBrand = (category_id, params) => {
    return defHttp.post({url:`/manager/goods/categoryBrand/${category_id}`, params}, {joinParamsToUrl: true});
}
//保存获取关联规格
export const saveCategorySpec = (category_id, params) => {
    return defHttp.post({url:`/manager/goods/categorySpec/${category_id}`, params}, {joinParamsToUrl: true});
}

//获取所有可用品牌
export const getBrandListData = (params) => {
    return defHttp.get({url:'/manager/goods/brand/all', params}, {joinParamsToUrl: true});
}
// 获取所有可用规格
export const getSpecificationList = (params) => {
    return defHttp.get({url:'/manager/goods/spec/all', params}, {joinParamsToUrl: true});
}

//获取分类列表数据
export const getAllCategoryList = (parent_id) => {
    return defHttp.get({url:`/manager/goods/category/${parent_id}/all-children`});
}

//获取分类列表数据
export const getCategoryTree = () => {
    return defHttp.get({url:`/manager/goods/category/allChildren`});
}

//  添加商品分类
export const insertCategory = (params) => {
    return defHttp.post({url:'/manager/goods/category', params}, {joinParamsToUrl: true});
}
//  添加商品分类
export const updateCategory = (params) => {
    return defHttp.put({url:'/manager/goods/category', params}, {joinParamsToUrl: true});
}
//删除商品分类
export const delCategory = (id) => {
    return defHttp.delete({url:`/manager/goods/category/${id}`});
}
// 禁用分类
export const disableCategory = (id, type) => {
    return defHttp.put({url:`/manager/goods/category/disable/${id}`, type});
}

//  获取商品规格分页列表
export const getSpecListData = (params) => {
    return defHttp.get({url:'/manager/goods/spec', params}, {joinParamsToUrl: true});
}
//  添加或修改规格设置
export const insertSpec = (params) => {
    return defHttp.post({url:'/manager/goods/spec', params}, {joinParamsToUrl: true});
}
//  添加或修改规格设置
export const updateSpec = (id,params) => {
    return defHttp.put({url:`/manager/goods/spec/${id}`, params}, {joinParamsToUrl: true});
}
//根据分类id获取关联规格
export const getCategorySpecListData = (category_id, params) => {
    return defHttp.get({url:`/manager/goods/categorySpec/${category_id}`, params}, {joinParamsToUrl: true});
}
//删除gUI个
export const delSpec = (id, params) => {
    return defHttp.delete({url:`/manager/goods/spec/${id}`, params}, {joinParamsToUrl: true});
}

// 查询某分类下的全部子分类列表
export const getGoodsCategory = (parent_id) => {
    return defHttp.get({url:`/manager/goods/category/${parent_id}/all-children`});
}

//  上架商品
export const upGoods = (id, params) => {
    return defHttp.put({url:`/manager/goods/goods/${id}/up`, params}, {joinParamsToUrl: true});
}

//  下架商品
export const lowGoods = (id, params) => {
    return defHttp.put({url:`/manager/goods/goods/${id}/under`, params}, {joinParamsToUrl: true});
}

//  获取商品sku分页列表
export const getGoodsSkuData = (params) => {
    return defHttp.get({url:'/manager/goods/goods/sku/list', params}, {joinParamsToUrl: true});
}

//  获取商品分页列表
export const getGoodsListData = (params) => {
    return defHttp.get({url:'/manager/goods/goods/list', params}, {joinParamsToUrl: true});
}
//  获取待审核商品分页列表
export const getAuthGoodsListData = (params) => {
    return defHttp.get({url:'/manager/goods/goods/auth/list', params}, {joinParamsToUrl: true});
}
//  审核商品
export const authGoods = (id, params) => {
    return defHttp.put({url:`/manager/goods/goods/${id}/auth`, params}, {joinParamsToUrl: true});
}

//查询分类绑定参数信息
export const getCategoryParamsListData = (id, params) => {
    return defHttp.get({url:`/manager/goods/categoryParameters/${id}`, params}, {joinParamsToUrl: true});
}

//查询商品绑定参数信息
export const getCategoryParamsByGoodsId = (goodsId, categoryId) => {
    return defHttp.get({url:`/manager/goods/parameters/${goodsId}/${categoryId}`});
}
//保存参数
export const insertGoodsParams = (params) => {
    return defHttp.post({url:'/manager/goods/parameters', params}, {joinParamsToUrl: true});
}
//更新参数
export const updateGoodsParams = (params) => {
    return defHttp.put({url:'/manager/goods/parameters', params}, {joinParamsToUrl: true});
}
//删除参数
export const deleteParams = (id, params) => {
    return defHttp.delete({url:`/manager/goods/parameters/${id}`, params}, {joinParamsToUrl: true});
}
//保存参数组
export const insertParamsGroup = (params) => {
    return defHttp.post({url:'/manager/goods/categoryParameters', params}, {joinParamsToUrl: true});
}
//更新参数组
export const updateParamsGroup = (params) => {
    return defHttp.put({url:'/manager/goods/categoryParameters', params}, {joinParamsToUrl: true});
}
//删除参数组
export const deleteParamsGroup = (id, params) => {
    return defHttp.delete({url:`/manager/goods/categoryParameters/${id}`, params}, {joinParamsToUrl: true});
}

//保存获取关联规格
export const getGoodsSpecInfo = (category_id, params) => {
    return defHttp.get({url:`/manager/goods/categorySpec/goods/${category_id}`, params}, {joinParamsToUrl: true});
}

//获取sku列表
export const getSkuPage = (params) => {
    return defHttp.get({url:`/manager/goodsSku/getByPage`, params}, {joinParamsToUrl: true});
}

//查看商品详情
export const getGoodsDetail = (id) => {
    return defHttp.get({url:`/manager/goods/goods/get/${id}`});
}

// 获取订单统计图表
export const getOrderChart = (params) => {
    return defHttp.get({url:`/manager/statistics/order`, params}, {joinParamsToUrl: true});
}

// 订单统计概览
export const getOrderOverView = (params) => {
    return defHttp.get({url:`/manager/statistics/order/overview`, params}, {joinParamsToUrl: true});
}

// 统计相关订单统计
export const statisticsOrderList = (params) => {
    return defHttp.get({url:`/manager/statistics/order/order`, params}, {joinParamsToUrl: true});
}

// 统计相关退单统计
export const statisticsOrderRefundList = (params) => {
    return defHttp.get({url:`/manager/statistics/order/refund`, params}, {joinParamsToUrl: true});
}


// 获取行业统计列表
export const goodsCategoryStatistics = (params) => {
    return defHttp.get({url:`/manager/statistics/goods/getCategoryByPage`, params}, {joinParamsToUrl: true});
}

// 获取统计列表,排行前一百的数据
export const goodsStatistics = (params) => {
    return defHttp.get({url:`/manager/statistics/goods`, params}, {joinParamsToUrl: true});
}


// 获取退款统计列表
export const refundStatistics = (params) => {
    return defHttp.get({url:`/manager/statistics/refund/order/getByPage`, params}, {joinParamsToUrl: true});
}

// 获取退款统计金额
export const refundPriceStatistics = (params) => {
    return defHttp.get({url:`/manager/statistics/refund/order/getPrice`, params}, {joinParamsToUrl: true});
}



//-------------------------------------------
/**
 * 发布商品 查询商品品类 分级查询（商城商品品类）
 * @param ids
 * @param params
 * @returns {Promise<any>}
 */
export const getGoodsCategoryLevelList = (ids, params) => {
  return defHttp.get({url: `/store/goods/category/${ids}/children`, params}, {joinParamsToUrl: true});
};

// 获取全部经营类目
export const getGoodsCategoryAll = () => {
  return defHttp.get({url: `/store/goods/category/all`}, {joinParamsToUrl: true});
};